<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "employee_photo".
 *
 * @property integer $id
 * @property string $employee_number
 * @property string $employee_name
 * @property string $image_name
 * @property string $image_content_type
 * @property string $image_url
 * @property resource $image_data
 * @property integer $image_width
 * @property integer $image_height
 * @property string $image_source_url
 * @property resource $image_source_data
 * @property string $memo
 * @property string $created_by
 * @property string $created_at
 * @property string $updated_by
 * @property string $updated_at
 */
class EmployeePhoto extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'employee_photo';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['employee_number'], 'required'],
            [['image_data', 'image_source_data'], 'string'],
            [['image_width', 'image_height'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['employee_number', 'employee_name', 'image_name', 'image_content_type', 'image_source_url', 'created_by', 'updated_by'], 'string', 'max' => 45],
            [['image_url'], 'string', 'max' => 255],
            [['memo'], 'string', 'max' => 2048],
            [['employee_number'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'employee_number' => Yii::t('app', 'Employee Number'),
            'employee_name' => Yii::t('app', 'Employee Name'),
            'image_name' => Yii::t('app', 'Image Name'),
            'image_content_type' => Yii::t('app', 'Image Content Type'),
            'image_url' => Yii::t('app', 'Image Url'),
            'image_data' => Yii::t('app', 'Image Data'),
            'image_width' => Yii::t('app', 'Image Width'),
            'image_height' => Yii::t('app', 'Image Height'),
            'image_source_url' => Yii::t('app', 'Image Source Url'),
            'image_source_data' => Yii::t('app', 'Image Source Data'),
            'memo' => Yii::t('app', 'Memo'),
            'created_by' => Yii::t('app', 'Created By'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_by' => Yii::t('app', 'Updated By'),
            'updated_at' => Yii::t('app', 'Updated At'),
        ];
    }

    public function getPrintName(){
        return sprintf('姓名: %s 工号: %s', $this->employee_name, $this->employee_number);
    }
}
